/*    */ package net.sourceforge.appgen.util;
/*    */ 
/*    */ import java.util.Comparator;
/*    */ 
/*    */ public class ClassNameComparator
/*    */   implements Comparator<String>
/*    */ {
/*    */   public int compare(String o1, String o2)
/*    */   {
/* 27 */     int c = 0;
/*    */ 
/* 29 */     c = compareTopPackage("java.", o1, o2);
/* 30 */     if (c != 0) {
/* 31 */       return c;
/*    */     }
/* 33 */     c = compareTopPackage("javax.", o1, o2);
/* 34 */     if (c != 0) {
/* 35 */       return c;
/*    */     }
/* 37 */     c = compareTopPackage("org", o1, o2);
/* 38 */     if (c != 0) {
/* 39 */       return c;
/*    */     }
/* 41 */     c = comparePackage(o1, o2);
/* 42 */     if (c != 0) {
/* 43 */       return c;
/*    */     }
/*    */ 
/* 46 */     return o1.compareTo(o2);
/*    */   }
/*    */ 
/*    */   private int compareTopPackage(String packageName, String o1, String o2) {
/* 50 */     boolean inPackage1 = o1.startsWith(packageName);
/* 51 */     boolean inPackage2 = o2.startsWith(packageName);
/*    */ 
/* 53 */     if ((inPackage1) && (!inPackage2)) {
/* 54 */       return -1;
/*    */     }
/* 56 */     if ((!inPackage1) && (inPackage2)) {
/* 57 */       return 1;
/*    */     }
/*    */ 
/* 60 */     return 0;
/*    */   }
/*    */ 
/*    */   private int comparePackage(String o1, String o2) {
/* 64 */     String packageName1 = ConventionUtils.getPackageName(o1);
/* 65 */     String packageName2 = ConventionUtils.getPackageName(o2);
/*    */ 
/* 67 */     if (!packageName1.equals(packageName2)) {
/* 68 */       return packageName1.compareTo(packageName2);
/*    */     }
/*    */ 
/* 71 */     return 0;
/*    */   }
/*    */ }

/* Location:           C:\Users\lzl6066\Downloads\net.sourceforge.appgen_1.2.0\plugins\net.sourceforge.appgen_1.2.0.201002031718\
 * Qualified Name:     net.sourceforge.appgen.util.ClassNameComparator
 * JD-Core Version:    0.6.0
 */